home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS04.ADF
/
image.ed
/
textreq.c
< prev
Wrap
C/C++ Source or Header
|
1985-10-26
|
9KB
|
207 lines
/************* text.requester2.c *********/
#include "intuall.h"
#include "imageedit.h"
#define TXHEIGHT80 8
extern struct TextAttr modfontattr;
extern SHORT txfont,txmode;
/* this file contains the information for the requester that allows you
* to specify adding text to a selected frame. */
/* there is one proportional gadget, which moves in the horizontal and
* vertical direction. It shows the system where, in the selected frame
* to put the text
*/
/* there are gadgets for the text type and drawmode as well */
struct Requester textrequest;
UBYTE textstring[10];
UBYTE textundo[10];
struct StringInfo textstringstuff = {
&textstring[0], /* default and final string */
&textundo[0], /* optional undo buffer (later) */
0, /* character position in buffer */
10, /* max characters in buffer */
0, /* buffer position of first displayed
* character */
0,0,0,0,0,NULL,0 }; /* intuition local variables */
APTR defaulttext = "test";
UWORD textsliderimage[] = {
0x03c0,
0x0ff0,
0x3ffc,
0xffff,
0x3ffc,
0x0ff0,
0x03c0 };
struct Image textimage = { /* image 16 bits wide but only using left 8
* so that left pointing arrow says where to
* put the text */
{0,0,8,7,1,&textsliderimage[0],0x1,0,} };
struct PropInfo textslider = {
FREEHORIZ | FREEVERT,
/* let it move freely in both directions */
0,0, /* initial values of horizontal, vert. pot */
0x3fff, /* HorizBody ... not using autoknob so this
* may not be necessary to set to other than 0 */
0x3fff, /* VertBody */
0,0,0,0,0,0,}; /* intuition's variables */
extern SHORT palette[];
/* text type, text mode, done, string gadget,
and positioning gadget. */
extern struct TextAttr TestFont;
struct IntuiText textreqtext[] = {
/* requester IntuiText for this color requester */
{ 0,1,JAM1, 5, 3, &TestFont, "Click To Change Mode:",
&textreqtext[1], }
{ 0,1,JAM1, 5, 13, &TestFont, "Click To Change Style:",
&textreqtext[2], }
{ 0,1,JAM1, 5, 30, &TestFont, "Pointer Positions Text",
&textreqtext[3], }
{ 0,1,JAM1, 5, 80, &TestFont, "Click In Text Box To Type",
&textreqtext[4], }
{ 0,1,JAM1, 25, 90, &TestFont, "Into Selected Frame",
&textreqtext[5], }
{ 0,1,JAM1, 5, 105, &TestFont, "Press Return To Draw Text",
&textreqtext[6], }
{ 0,1,JAM1, 5, 115, &TestFont, "Click CANCEL To Exit",
NULL,} /* gadget text not linked in */
/* gadget IntuiText for this color requester */
{ 1,0,JAM2, 1, 0, &TestFont, "JAM1",
NULL, }
{ 1,0,JAM2, 1, 0, &TestFont, "JAM2",
NULL, }
{ 1,0,JAM2, 1, 0, &TestFont, "Topaz-80",
NULL, }
{ 1,0,JAM2, 1, 0, &TestFont, "Topaz-60",
NULL,}
{ 1,0,JAM2, 1, 0, &TestFont, "CANCEL",
NULL }
};
/* the OK gadget lets people decide accept the colors they have */
/* chosen. Should also install a default colors gadget! */
struct Gadget trg[] = { /* CANCEL */
{ &trg[1], /* address of next gadget */
205,115,60,9, /* left,top,width,height of hitbox */
GADGHCOMP, /* flags */
RELVERIFY | GADGIMMEDIATE | ENDGADGET,
/* tell me only when he releases the
* mouse button and if over the
* gadget at that time */
REQGADGET | BOOLGADGET, /* is a requestor, bool */
NULL, /* BORDER descriptor */
NULL, /* SELECT descriptor */
&textreqtext[11], /* Cancel */
0, /* mutual exclusion (could use) */
NULL, /* special info */
TEXTWRITEGADGETS + 1, /* gadget identifier, user */
NULL, } /* user data pointer */
{ &trg[2], /* text mode */
190,3,40,9,
GADGHCOMP,
RELVERIFY | GADGIMMEDIATE,
REQGADGET | BOOLGADGET,
NULL,
NULL,
&textreqtext[7],
0,
NULL,
TEXTWRITEGADGETS + 2,
NULL,}
{ &trg[3], /* text style */
190,13,80,9,
GADGHCOMP,
RELVERIFY | GADGIMMEDIATE,
REQGADGET | BOOLGADGET,
NULL,
NULL,
&textreqtext[9],
0,
NULL,
TEXTWRITEGADGETS + 3,
NULL,}
{&trg[4], /* this is string gadget */
55,60,140,10, /* left,top,width,height of hitbox */
GADGHCOMP, /* Flags, complement mode, needed
* as of this writing for string
* gadgets */
RELVERIFY | ENDGADGET, /* Activation flags, when user hits
* return, terminates
* input and deselects gadget */
REQGADGET | STRGADGET, /* is a requestor, string */
NULL, /* BORDER descriptor */
NULL, /* SELECT descriptor */
NULL, /* intiutext to write there */
0, /* mutual exclusion (could use) */
&textstringstuff, /* special info */
TEXTWRITEGADGETS, /* gadget identifier, user */
NULL, } /* user data pointer */
/* dual-proportional gadget */
{ NULL, /* next gadget in this list */
190,25, /* left edge, top edge of hitbox */
80,42, /* width and height of hitbox */
GADGIMAGE | GADGHNONE, /* flags */
GADGIMMEDIATE | RELVERIFY, /* activation flags */
PROPGADGET | REQGADGET, /* this is a proportional gadget */
&textimage, /* render normally with this image */
&textimage, /* render highlighted with this one */
NULL, /* no text for this prop gadget */
0x0, /* mutual exclude */
&textslider, /* special info = define of prop */
TEXTWRITEGADGETS + 4, /* this gadget's identifier for me */
NULL } }; /* no user data on this one */
InitTextRequest()
{
BYTE *s, *t;
InitRequester(&textrequest);
textrequest.LeftEdge = 20;
textrequest.TopEdge = 20;
textrequest.Width = 280;
textrequest.Height = 130;
textrequest.ReqGadget = &trg[0];
textrequest.ReqText = &textreqtext[0];
textrequest.BackFill = 1;
textrequest.ReqBorder = NULL;
s = &textstring[0]; /* copy default string for text. */
t = defaulttext;
while((*s++ = *t++) != '\0')
; /* do nothing */
/* set initial text mode and style */
txfont = 80; /* use an 80 column font */
txmode = 1; /* jam 1 color */
modfontattr.ta_Name = "topaz.font";
modfontattr.ta_YSize = TXHEIGHT80;
modfontattr.ta_Style = 0;
modfontattr.ta_Flags = 0;
return(0);
}